package com.rivulet.doj_backend.controller;


import com.rivulet.doj_backend.service.QuestionService;
import com.rivulet.doj_backend.tools.ResultFul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin(origins = {"http://localhost:8080", "null"})
@RestController
@RequestMapping(value = "/doj")
public class QuestionController {
    @Autowired
    QuestionService questionService;
    @RequestMapping(value = ("/questions/{question_id}"),method = RequestMethod.POST)
    public ResultFul inquiryInformation(@PathVariable Integer question_id) {
        return questionService.inquiryQuestion(question_id);
    }
    @RequestMapping(value = ("/questions"),method = RequestMethod.POST)
    public ResultFul showInformation(@RequestParam("page") Integer page) {
        return questionService.inquiryQuestion(page);
    }
    @RequestMapping(value = ("/questions/{user_id}/upload"),method = RequestMethod.POST)
    public ResultFul addQuestion(@PathVariable Integer user_id,@RequestParam("question_title") String question_title,@RequestParam("question_content") String question_content,@RequestParam("diffculty") Integer diffculty,@RequestParam("label_id") Integer label_id,@RequestParam("question_id")Integer question_id) {
        return questionService.addQuestion(user_id, question_title, question_content, diffculty,label_id,question_id);
        
    }



}
